<template>
	<view class="adpop-box" v-if="state.show">
		<view class="img-box">
			<image class="img" :src="shopConfigStore.config.indexPopupWindowImageUrl" mode="widthFix"></image>
			<view class="btn" @click="hanldeCloseAdpop">
				<image class="icon" :src="handleStaticResources('/static/images/icon/icon-close.png')"></image>
			</view>
		</view>
	</view>
</template>
<script setup lang="ts">
	import { reactive, onMounted } from 'vue';
	import type { ShopConfigStoreType } from '@/core/models';
	import { useShopConfigStore } from '@/core/store';
	import { ShowPopupWindowEnum } from '@/core/enum';
	import { handleStaticResources } from '@/core/utils';

	// 获取项目配置
	const shopConfigStore : ShopConfigStoreType = useShopConfigStore();

	const state = reactive<{
		show : boolean,
	}>({
		show: false,
	})

	const hanldeCloseAdpop = () => {
		state.show = !state.show;
	}

	onMounted(() => {
		if (shopConfigStore.config.showIndexPopupWindow === ShowPopupWindowEnum.yes) {
			state.show = true;
		}
	})
</script>
<style lang="scss" scoped>
	@import './home-adpop.scss';
</style>